import java.util.Arrays;

/**
 * @ClassName BubbleSort
 * @Description 冒泡排序
 * @Author 李明忠
 * @Date 2025/5/20 21:07
 * @Version 1.0
 */
public class BubbleSort {
    public static void bubbleSort(int[] array) {
        for (int i = 0; i < array.length - 1; i++) {
            for (int j = 0; j < array.length - 1 - i; j++) {
                if(array[j] > array[j + 1]) {
                    int tmp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = tmp;
                }
            }
        }
    }
    public static void main(String[] args) {
        int[] array = {10,9,8,7,6,5,4,3,2,1};
        System.out.println("排序前：" + Arrays.toString(array));
        bubbleSort(array);
        System.out.println("排序后：" + Arrays.toString(array));
    }
}
